package com.cxc.template;

import com.cxc.entity.Apple;
import com.cxc.entity.Banana;
import com.cxc.entity.Fruite;
import com.cxc.entity.Orange;
import com.cxc.factory.FruiteSimpleFactory;
import com.cxc.strategy.Discount;
import com.cxc.strategy.FullDiscount;
import com.cxc.strategy.NewerDiscount;
import com.cxc.strategy.SecondDiscount;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class Client {
    private static Map<String, Discount> discountMap = new HashMap<>();

    static{
        discountMap.put("full",new FullDiscount());
        discountMap.put("newer",new NewerDiscount());
        discountMap.put("second",new SecondDiscount());
    }

    public static void main(String[] args) {

        List<Fruite> products = new ArrayList();
        products.add(new Apple());
        products.add(new Banana());
        products.add(new Orange());

        ShoppingCart cart = new CartShopping(products);
        //注入优惠方案
        String discount = "second";
        cart.setDiscount(discountMap.get(discount));

        cart.submitOrder();

    }
}
